package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.OrderPayCodeMapperExt;
import com.lzy.product.dtos.OrderPayCodeDto;
import com.lzy.product.entity.OrderPayCode;
import com.lzy.product.service.OrderPayCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2017/11/29.
 */
@Service
public class OrderPayCodeServiceImpl implements OrderPayCodeService {

    @Autowired
    OrderPayCodeMapperExt orderPayCodeMapperExt;

    @Override
    public Long insert(OrderPayCodeDto dto) {
        OrderPayCode orderPayCode = DozerUtils.map(dto, OrderPayCode.class);
        return orderPayCodeMapperExt.insertSelective(orderPayCode) > 0 ? orderPayCode.getOrderId() : 0L;
    }

    @Override
    public Boolean update(OrderPayCodeDto dto) {
        return orderPayCodeMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, OrderPayCode.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return orderPayCodeMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public OrderPayCodeDto findById(Long id) {
        return DozerUtils.map(orderPayCodeMapperExt.selectByPrimaryKey(id), OrderPayCodeDto.class);
    }

    @Override
    public List<OrderPayCodeDto> query(OrderPayCodeDto dto) {
        return null;
    }

    @Override
    public List<OrderPayCodeDto> selectList(OrderPayCodeDto dto) {
        return orderPayCodeMapperExt.selectList(dto);
    }
}
